﻿@using ZhouYu.DreamTour.Web.Models;
@using ZhouYu.DreamTour.Model;
@{
    var user = ViewBag.user as UserInfo;
    var UserInfo = UserInfoContext.userInfoContext.UserInfo;
}
<!DOCTYPE html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>中国梦想游-会员登录页</title>
    <link href="~/css/style.css" rel="stylesheet" type="text/css" />
    <link href="~/css/common.css" rel="stylesheet" type="text/css" />
    <link href="~/layui-v2.5.4/layui/css/layui.css" rel="stylesheet" type="text/css" />
    <link href="~/layui-v2.5.4/layui/css/modules/layer/default/layer.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="~/js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="~/layui-v2.5.4/layui/layui.js"></script>
    <script type="text/javascript" src="~/layui-v2.5.4/layui/lay/modules/layer.js"></script>
    <script type="text/javascript" src="~/js/Format.js"></script>
    <style>
        /*发送验证码样式*/
        #getCode {
            background: #ff6700;
            border: none;
            color: white;
            font-weight: 800;
            border-radius: 3px;
            padding: 0.8%;
            margin-left: 2%;
        }

        /*发送验证码样式*/
        #SendEmail {
            background: #ff6700;
            border: none;
            color: white;
            font-weight: 800;
            border-radius: 3px;
            padding: 0.8%;
            margin-left: 2%;
        }
    </style>
</head>
<body>
    <div class="top_hw clearfix">
        <div class="top_h clearfix">
            <div class="top_hl"><span>欢迎来到中国梦想游，让你的梦想全程免费自由行！</span> 预定热线：<b>0571-63322269</b></div>
            <div class="top_hr">
                @if (UserInfo == null)
                {
                    <a href="/Home/User_Register">会员注册</a>
                    <span>|</span> <a href="/Home/User_Login">登录</a>
                    <span>|</span> <a href="#">梦想收藏</a> <span>|</span> <a href="#">设为首页</a>
                    @*<a>
                欢迎你，来到新世界旅行网！
            </a>*@
                }
                else
                {
                    <a href="/Home/User_Center">会员中心</a>
                    <span>|</span> <a href="#">梦想收藏</a> <span>|</span> <a href="#">设为首页</a> <span>|</span> <a href="/Login/LoginOut">退出</a> <span>|</span>
                    <a>
                        欢迎你，<span>@UserInfo.User_Name</span>来到新世界旅行网！
                    </a>
                }
            </div>
        </div>
    </div>
    <div class="head_w">
        <div class="head_t clearfix">
            <div class="logo"><img src="~/images/logo.jpg"></div>
            <div class="rx_line"><img src="~/images/rx.jpg"></div>
        </div>
    </div>
    <div class="mainNav clearfix">
        <ul class="Nav_ul">
            <li><a href="/Home/Index">首页</a><img src="~/images/nav_line.jpg"></li>
            <li><a href="/Home/Route">旅游路线</a><img src="~/images/nav_line.jpg"></li>
            <li><a href="/Home/Scenic">旅游景点</a><img src="~/images/nav_line.jpg"></li>
            <li><a href="/Home/CateringAccommodation">餐饮住宿</a><img src="~/images/nav_line.jpg"></li>
            <li><a href="/Home/Traffic_DatailsOne">交通线路</a><img src="~/images/nav_line.jpg"></li>
            <li><a href="/Home/Group">旅游团购</a><img src="~/images/nav_line.jpg"></li>
            <li><a href="/Home/Specialty">地方特产</a><img src="~/images/nav_line.jpg"></li>
            <li><a href="/Home/AutoGenerationIntro">自动生成简介</a><img src="~/images/nav_line.jpg"></li>
            <li><a href="/Home/Team_Join">团队简介</a><img src="~/images/nav_line.jpg"></li>
            <li><a href="/Home/Itinerary_Details">行程导航</a></li>
        </ul>
    </div>
    <div class="b_wrap">
        <div class="current"><span>当前所在地：</span><a href="/Home/Index">首页</a> >> <a href="/Home/User_Center">会员中心</a></div>
        <div class="fmember">
            <div class="fmleft">
                <div class="fmleft_top"><img src="~/images/fmbt1.png" border="0"></div>
                <div class="fmlist">
                    <ul>
                        <li class="f1">订单中心</li>
                        <li> >><a href="/Home/User_Order">我的订单</a> </li>
                        <li> >><a href="/Home/User_Colleague">发布结伴同行</a> </li>
                        <li> >><a href="/Home/User_Apply">我申请的结伴同行</a> </li>
                        <li> >><a href="/Home/User_Comment">我的点评</a> </li>
                        <li class="f2"> >><a href="/Home/User_Questions">我的提问</a> </li>
                    </ul>
                    <ul>
                        <li class="f1">我的优惠卡券</li>
                        <li> >><a href="/Home/User_CashAccount">现金账号</a> </li>
                        <li> >><a href="/Home/User_AllowanceVol">抵用券</a> </li>
                        <li class="f2"> >><a href="/Home/User_TouristVol">旅游券</a> </li>
                    </ul>
                    <ul>
                        <li class="f1">账户信息</li>
                        <li> >><a href="/Home/User_Data">个人资料</a> </li>
                        <li> >><a href="/Home/User_AccountSecurity">账户安全</a> </li>
                        <li>
                            >>
                            <a href="/Home/User_Bank">我的银行卡</a>
                        </li>
                        <li> >><a href="/Home/User_Integral">我的积分</a> </li>
                        <li> >><a href="/Home/User_UpdatePwd">修改密码</a> </li>
                        <li class="f2"> >><a href="/Home/User_Address">配送地址</a> </li>
                    </ul>
                </div>
            </div>
            <div class="fmright">
                <div class="fmr1">
                    <div class="fmr1_top">账户安全</div>
                    <div class="fmr1_m">
                        <div class="faq">
                            @if (user.User_Telphone == null)
                            {
                                <span>注册手机： 	暂未设置 <a href="#" class="editTel">设置手机</a><br></span>
                            }
                            else
                            {
                                <span>注册手机： 	@user.User_Telphone。 <a href="#" class="editTel">设置手机</a><br></span>
                            }
                            <input type="text" id="User_Telphone" placeholder="请输入需要设置的手机号" class="telHide" style="display:none" /><span id="telInfo" style="margin-left:1%;color:gray;display:none" class="telHide"></span><br class="telHide" style="display:none" />
                            <input type="text" id="Code" placeholder="请输入六位验证码" class="telHide" style="display:none" />
                            <input type="button" id="getCode" value="获取验证码" class="telHide" style="display:none" /><br class="telHide" style="display:none" />
                            <input type="button" id="commitTel" value="保存并更改" class="telHide layui-btn" style="display:none;margin-top:2%" /><br class="telHide" style="display:none" />
                            @if (user.User_Telphone == null)
                            {
                                <span>注册邮箱： 	暂未设置 <a href="#" class="editEmail">更换邮箱</a><br></span>
                            }
                            else
                            {
                                <span>注册邮箱： 	@user.User_Email <a href="#" class="editEmail">更换邮箱</a><br></span>
                            }
                            <input type="text" id="User_Email" placeholder="请输入需要设置的邮箱地址" class="emailHide" style="display:none" /><span id="EmailInfo" style="margin-left:1%;color:gray;display:none" class="emailHide"></span><br class="emailHide" style="display:none" />
                            <input type="text" id="ECode" placeholder="请输入六位验证码" class="emailHide" style="display:none" />
                            <input type="button" id="SendEmail" value="获取验证码" class="emailHide" style="display:none" /><br class="emailHide" style="display:none" />
                            <input type="button" id="commitEmail" value="保存并更改" class="emailHide layui-btn" style="display:none;margin-top:2%" /><br class="emailHide" style="display:none" />
                            上次登陆： 	@user.User_LoginTime<br>
                            IP地址： 	@user.User_LoginIp<br>
                            @*登陆地点： 	浙江省 杭州市  <a href="#">(不是您登录的？请点击这里)</a>*@
                        </div>


                        <div class="faq1">您的安全保护服务</div>
                        <div class="faq2">
                            <img src="~/images/ficon4.png" align="absmiddle"><img src="~/images/ficon4.png" align="absmiddle"><img src="~/images/ficon4.png" align="absmiddle"><img src="~/images/ficon4.png" align="absmiddle"><img src="~/images/ficon4.png" align="absmiddle">&nbsp;&nbsp;&nbsp;&nbsp;身份认证&nbsp;&nbsp;&nbsp;&nbsp;提升您的途牛帐号安全性。<br>
                            <img src="~/images/ficon4.png" align="absmiddle"><img src="~/images/ficon4.png" align="absmiddle"><img src="~/images/ficon5.png" align="absmiddle"><img src="~/images/ficon5.png" align="absmiddle"><img src="~/images/ficon5.png" align="absmiddle">&nbsp;&nbsp;&nbsp;&nbsp;密码保护&nbsp;&nbsp;&nbsp;&nbsp;密码安全性更高账号更安全，请使用尽量复杂的密码。<a href="#">[修改密码]</a><br>
                            <img src="~/images/ficon5.png" align="absmiddle"><img src="~/images/ficon5.png" align="absmiddle"><img src="~/images/ficon5.png" align="absmiddle"><img src="~/images/ficon5.png" align="absmiddle"><img src="~/images/ficon5.png" align="absmiddle">&nbsp;&nbsp;&nbsp;&nbsp;安全问题&nbsp;&nbsp;&nbsp;&nbsp;请尽量设置您的安全问题以便找回密码。<a href="#">[设置]</a><br>
                            <img src="~/images/ficon4.png" align="absmiddle"><img src="~/images/ficon5.png" align="absmiddle"><img src="~/images/ficon5.png" align="absmiddle"><img src="~/images/ficon5.png" align="absmiddle"><img src="~/images/ficon5.png" align="absmiddle">&nbsp;&nbsp;&nbsp;&nbsp;手机验证&nbsp;&nbsp;&nbsp;&nbsp;验证手机后，您即可享受丰富的手机服务。<br>
                            <img src="~/images/ficon4.png" align="absmiddle"><img src="~/images/ficon4.png" align="absmiddle"><img src="~/images/ficon4.png" align="absmiddle"><img src="~/images/ficon4.png" align="absmiddle"><img src="~/images/ficon5.png" align="absmiddle">&nbsp;&nbsp;&nbsp;&nbsp;邮箱验证&nbsp;&nbsp;&nbsp;&nbsp;验证邮箱后，您可以及时获得订单信息。<br>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script>
    $(".editTel").click(function () {
        $(".telHide").toggle();
    });

    $(".editEmail").click(function () {
        $(".emailHide").toggle();
    });


    //修改手机方法
    function EditTel() {
        var data = {};
        data.User_Telphone = $("#User_Telphone").val();
        $.ajax({
            url: "/User/EditUserTel",
            data: data,
            type: "post",
            success: function (result) {
                if (result.Success) {
                    alert("修改成功！");
                    window.location.reload(true);
                }
                else {
                    alert("修改失败！");
                }
            }
        });
    }

    //手机注册按钮点击事件
    $("#commitTel").click(function () {
        //检查验证码
        var data = {};
        data.TelPhone = $("#User_Telphone").val();
        data.Code = $("#Code").val();
        $.ajax({
            url: "/User/CheckCodeRegister",
            type: "post",
            data: data,
            success: function (result) {
                if (result.Success) {
                    //调用修改方法
                    EditTel();
                }
                else {
                    alert("修改失败！请填入信息！");
                }
            }
        });
    });

    //手机号码
    var tel = false;
    //邮箱地址
    var EmailAddress = false;

    //手机号码失去焦点事件
    $("#User_Telphone").blur(function () {
        tel = CheckUserTel();
    });
    //邮箱地址失去焦点事件
    $("#User_Email").blur(function () {
        EmailAddress = CheckEmail();
    });

    //检查手机号11位
    function CheckUserTel() {
        var tel = $("#User_Telphone").val();
        if (tel == "") {
            $("#telInfo").text("手机号不能为空！");
            $("#telInfo").css("color", "red");
            return false;
        }
        var reg = /^1([38]\d|5[0-35-9]|7[3678])\d{8}$/;
        if (reg.test(tel)) {
            $("#telInfo").text("√");
            $("#telInfo").css("color", "green");
            return true;
        } else {
            $("#telInfo").text("手机号必须为11位");
            $("#telInfo").css("color", "red");
            return false;
        }
    }

    //发送手机验证码按钮触发事件
    $("#getCode").click(function () {
        if (tel) {
            var telphone = $("#User_Telphone").val();
            $.ajax({
                url: "/User/AddSmsInfoRegister?tel=" + telphone,
                type: "post",
                success: function (result) {
                    if (result.Success) {
                        alert("发送成功!");
                        SendCode();
                    }
                    else {
                        alert("发送失败！");
                    }
                }
            })
        }
    });

    //发送手机验证码方法
    function SendCode() {
        //禁用
        $("#getCode").attr("disabled", "disabled");
        $("#getCode").css("background-color", "gray");
        var time = 60;
        $("#getCode").val(time + "S之后再发送");
        var timer = setInterval(function () {
            if (time > 0) {
                time--;
                $("#getCode").val(time + "S之后再发送");
            }
            else {
                $("#getCode").removeAttr("disabled").css("background-color", "#ff6700");
                $("#getCode").val("获取验证码");
                clearInterval(timer);
            }
        }, 1000);
    }




    //发送邮箱验证码方法
    function SendEmail() {
        //禁用
        $("#SendEmail").attr("disabled", "disabled");
        $("#SendEmail").css("background-color", "gray");
        var time = 60;
        $("#SendEmail").val(time + "S之后再发送");
        var timer = setInterval(function () {
            if (time > 0) {
                time--;
                $("#SendEmail").text(time + "S之后再发送");
            }
            else {
                $("#SendEmail").removeAttr("disabled").css("background-color", "#ff6700");
                $("#SendEmail").text("发送邮箱验证码");
                clearInterval(timer);
            }
        }, 1000);
    }


    //发送邮箱验证码按钮点击事件
    $("#SendEmail").click(function () {
        var email = $("#User_Email").val();
        $.ajax({
            url: "/User/SendEmailCode?email=" + email,
            type: "post",
            success: function (result) {
                if (result.Success) {
                    alert("发送成功,请查收！");
                    SendEmail();
                }
                else {
                    alert("发送失败！");
                }
            }
        });
    });



    //检查邮箱格式
    function CheckEmail() {
        if ($.trim($('#User_Email').val()).length == 0) {
            $("#EmailInfo").text("邮箱地址不能为空！");
            $("#EmailInfo").css("color", "red");
            return false;
        }
        //验证邮箱
        if ($("#User_Email").val().match(/^[a-zA-Z0-9]{1}[\\.a-zA-Z0-9_-]*[a-zA-Z0-9]{1}@@[a-zA-Z0-9]+[-]{0,1}[a-zA-Z0-9]+[\\.]{1}[a-zA-Z]+[\\.]{0,1}[a-zA-Z]+$/)) {
            $("#EmailInfo").text("√");
            $("#EmailInfo").css({ "color": "green" });
            return true;
        }
        else {
            $("#EmailInfo").text("邮箱格式不正确！");
            $("#EmailInfo").css("color", "red");
            return false;
        }
    }


    //修改邮箱
    function EditEmail() {
        var data = {};
        data.User_Email = $("#User_Email").val();
        $.ajax({
            url: "/User/EditUserEmail",
            data: data,
            type: "post",
            success: function (result) {
                if (result.Success) {
                    alert("修改成功！");
                    window.location.reload(true);
                }
                else {
                    alert("修改失败！");
                }
            }
        });
    }

    //保存提交按钮点击事件
    $("#commitEmail").click(function () {
        //进行非空验证
        if (CheckEmailInfoIsNull()) {
            //检查验证码
            var data = {};
            data.Email = $("#User_Email").val();
            data.Code = $("#ECode").val();
            $.ajax({
                url: "/User/CheckEmailCode",
                type: "post",
                data: data,
                success: function (result) {
                    if (result.Success) {
                        //调用修改邮箱方法
                        EditEmail();
                    }
                    else {
                        alert("注册失败！请填入信息！");
                    }
                }
            });
        }
    });


    //邮箱注册信息验证非空
    function CheckEmailInfoIsNull() {
        if ($("#User_Email").val() == "") {
            layer.msg('邮箱地址不能为空！', {
                title: '提示框',
                icon: 1,
            });
            return false;
        }
        if ($("#ECode").val() == "") {
            layer.msg('验证码不能为空！', {
                title: '提示框',
                icon: 1,
            });
            return false;
        }
        return true;
    }
</script>
</html>

